package cn.wolfcode.web.controller;

import cn.wolfcode.Enum.AppointmentEnums;
import cn.wolfcode.domain.Appointment;
import cn.wolfcode.domain.SystemDictionaryItem;
import cn.wolfcode.qo.JsonResult;
import cn.wolfcode.service.IAppointmentService;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.ISystemDictionaryItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/appointment/index")
public class IndexController {

    @Autowired
    private IBusinessService businessService;

    @Autowired
    private IAppointmentService appointmentService;

    @Autowired
    private ISystemDictionaryItemService systemDictionaryItemService;

    @RequestMapping("/appointment/index")
    public String index(Model model){
        List<SystemDictionaryItem>items= systemDictionaryItemService.selectBySn("business");
        model.addAttribute("items",items);
        model.addAttribute("business",businessService.listAll());
        return "index";
    }

    @RequestMapping("/appointment/save")
    public JsonResult save(Appointment appointment){
        JsonResult jsonResult = new JsonResult();
         appointment.setStatus(AppointmentEnums.PEND.getValue());
         appointmentService.save(appointment);
         return jsonResult;
    }
}
